import uuid

from django.db import models


# Create your models here.

class AppUser(models.Model):
    """
     App用户表(后台专用)
     """
    user_account = models.CharField(max_length=11, verbose_name="登录账号（手机号）")
    password = models.CharField(max_length=32, verbose_name="登录账号（手机号）")
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    weibo_openid = models.CharField(null=True, blank=True, verbose_name="微博登录凭证", max_length=40)
    wechart_openid = models.CharField(null=True, blank=True, verbose_name="微信登录凭证", max_length=40)
    qq_openid = models.CharField(null=True, blank=True, verbose_name="qq登录凭证", max_length=40)

    class Meta:
        verbose_name = 'App用户表'
        verbose_name_plural = 'App用户表'
        db_table = 'app_user'

    def __str__(self):
        return "%s" % self.user_account


class UserInfo(models.Model):
    """
     用户信息
     """
    SEX_CHOICE = ((0, '男'), (1, '女'))
    IS_CERTIFICATION_CHOICE = ((0, '未审核'), (1, '已审核'), (2, '审核失败'), (3, '待审核'))

    user = models.OneToOneField('AppUser', verbose_name="用户id")
    portrait = models.CharField(max_length=500, null=True, blank=True, verbose_name="头像")
    weight = models.FloatField(null=True, blank=True, verbose_name="体重(kg)")
    height = models.FloatField(null=True, blank=True, verbose_name="身高(cm)")
    exp = models.IntegerField(default=0, verbose_name="用户经验")
    create_time = models.DateTimeField(null=True, blank=True, auto_now_add=True, verbose_name="创建时间")
    nick_name = models.CharField(null=True, blank=True, verbose_name="昵称", max_length=40, unique=True)
    sex = models.IntegerField(verbose_name="性别", default=0)
    city = models.CharField(null=True, blank=True, verbose_name="所属城市", max_length=40)
    age = models.IntegerField(null=True, blank=True, verbose_name="年龄", default=18)
    birth_year = models.IntegerField(null=True, blank=True, verbose_name="出生年", default=1999)
    birth_month = models.IntegerField(null=True, blank=True, verbose_name="出生月", default=1)
    is_notify = models.BooleanField(default=False, verbose_name="是否提醒")
    balance = models.DecimalField(default=0, max_digits=15, decimal_places=2, null=True, blank=True,
                                  verbose_name='钱包余额')
    total_sport_time = models.FloatField(null=True, blank=True, verbose_name="总运动时长", default=0.0)
    total_week_sport_time = models.FloatField(null=True, blank=True, verbose_name="周总运动时长",
                                              default=0.0)
    total_day_sport_time = models.FloatField(null=True, blank=True, verbose_name="每日总运动时长",
                                             default=0.0)
    continuity_sign = models.IntegerField(null=True, blank=True, default=0, verbose_name="连续签到天数")
    target_weight = models.FloatField(null=True, blank=True, verbose_name="目标体重(kg)", default=0)
    medals = models.CharField(null=True, blank=True, verbose_name="勋章列表", max_length=20)
    bluetooth_key = models.CharField(null=True, blank=True, verbose_name="蓝牙信息", max_length=100)
    is_vip = models.BooleanField(default=False, verbose_name="是否是vip")
    is_certification = models.IntegerField(choices=IS_CERTIFICATION_CHOICE, default=0, verbose_name="是否实名认证")
    idcard_no = models.CharField(max_length=50, null=True, blank=True, verbose_name="身份证号")
    idcard_img_bg = models.CharField(max_length=500, null=True, blank=True, verbose_name="身份证反面")
    idcard_img_fg = models.CharField(max_length=500, null=True, blank=True, verbose_name="身份证正面")
    sport_day = models.IntegerField(verbose_name="运动天数", default=0)
    flush_affair_time = models.DateTimeField(null=True, blank=True, auto_now_add=True, verbose_name="最后一次刷新所有帖子时间")
    flush_homepage_time = models.DateTimeField(null=True, blank=True, auto_now_add=True, verbose_name="最后一次刷新个人信息时间")
    # 连体衣 版本号
    hardware_01_version = models.ForeignKey("HardwareVersionModel", null=True, blank=True, default=None,
                                            verbose_name="连体衣 版本号", related_name="relate_hardware_01_version")
    # 上衣版本号
    hardware_02_version = models.ForeignKey("HardwareVersionModel", null=True, blank=True, default=None,
                                            verbose_name="上衣版本号", related_name="relate_hardware_02_version")
    # 裤子版本号
    hardware_03_version = models.ForeignKey("HardwareVersionModel", null=True, blank=True, default=None,
                                            verbose_name="裤子版本号", related_name="relate_hardware_04_version")
    # 未知版本号
    hardware_00_version = models.ForeignKey("HardwareVersionModel", null=True, blank=True, default=None,
                                            verbose_name="未知版本号", related_name="relate_hardware_00_version")
    # app版本号
    app_version = models.CharField(max_length=10, null=True, blank=True, default=None, verbose_name="未知版本号")

    class Meta:
        verbose_name = '用户信息'
        verbose_name_plural = '用户信息'
        db_table = 'user_info'

    def __str__(self):
        return "%s" % self.nick_name


class UserMedal(models.Model):
    medal_name = models.CharField(null=True, blank=True, max_length=20, verbose_name="勋章名字")
    medal_pic = models.CharField(null=True, blank=True, max_length=200, verbose_name="勋章图片")

    class Meta:
        verbose_name = '用户勋章'
        verbose_name_plural = '用户勋章'
        db_table = 'user_medal'

    def __str__(self):
        return "%s" % self.id


class MachineInfo(models.Model):
    """
    设备信息
    """
    uuid = models.CharField(verbose_name="设备识别码", max_length=40)
    name = models.CharField(verbose_name="设备名字", max_length=40)

    class Meta:
        verbose_name = '设备信息'
        verbose_name_plural = '设备信息'
        db_table = 'machine_info'

    def __str__(self):
        return "%s" % self.name


class ConnectionRecord(models.Model):
    user = models.ForeignKey('UserInfo', verbose_name="用户id")
    start_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    end_time = models.DateTimeField(null=True, blank=True, auto_now_add=False, verbose_name="结束连接时间")
    duration = models.FloatField(null=True, blank=True, verbose_name="连接时长")
    data_package = models.TextField(null=True, blank=True, verbose_name="心率数据包")
    avg_heart_rate = models.IntegerField(null=True, blank=True, verbose_name="平均心率", default=0)
    max_heart_rate = models.IntegerField(null=True, blank=True, verbose_name="最大心率", default=0)
    min_heart_rate = models.IntegerField(null=True, blank=True, verbose_name="最小心率", default=0)
    pre_start_time = models.DateTimeField(auto_now_add=True, verbose_name="上次开始时间")

    class Meta:
        verbose_name = '设备连接记录'
        verbose_name_plural = '设备连接记录'
        db_table = 'connection_record'

    def __str__(self):
        return "%s" % self.user.nick_name


class ConnectionTypeRecord(models.Model):
    TYPE_CHOICE = ((1, '减肥'),
                   (2, '紧致'),
                   (3, '理疗'),)
    connect = models.ForeignKey('ConnectionRecord', verbose_name='连接记录')
    user = models.ForeignKey('UserInfo', verbose_name='用户')
    type = models.IntegerField(default=0, verbose_name='连接类别', null=True, blank=True, choices=TYPE_CHOICE)
    start_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    end_time = models.DateTimeField(null=True, blank=True, auto_now_add=False, verbose_name="结束连接时间")
    duration = models.FloatField(null=True, blank=True, verbose_name="连接时长")

    class Meta:
        verbose_name = '设备分类连接记录'
        verbose_name_plural = '设备分类连接记录'
        db_table = 'connection_type_record'

    def __str__(self):
        return "%s" % self.user.nick_name


class HardwareUpgrade(models.Model):
    category = models.CharField(null=True, blank=True, verbose_name="类别", max_length=10)
    manufacture = models.CharField(null=True, blank=True, verbose_name="制造厂商", max_length=100)
    hw_version = models.CharField(null=True, blank=True, verbose_name="硬件版本", max_length=100)
    fw_version = models.CharField(null=True, blank=True, verbose_name="固件版本", max_length=100)
    hardware_url = models.CharField(null=True, blank=True, verbose_name="硬件升级包url", max_length=100)
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")


class BodyData(models.Model):
    PHYSIQUE_CHOICE = (
        (1, '隐性肥胖型'), (2, '脂肪过多型'), (3, '肥胖型'), (4, '肌肉不足型'), (5, '健康匀称型'), (6, '超重型'), (7, '消瘦型'), (8, '低脂肪型'),
        (9, '运动员型'))
    user = models.ForeignKey('UserInfo', verbose_name="用户id")
    start_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    bmi = models.FloatField(null=True, blank=True, verbose_name="bmi")
    fat_percentage = models.FloatField(null=True, blank=True, verbose_name="体脂率")
    water_weight = models.FloatField(null=True, blank=True, verbose_name="水分")
    visceral_fat_percentage = models.FloatField(null=True, blank=True, verbose_name="内脏脂肪")
    muscle_weight = models.FloatField(null=True, blank=True, verbose_name="肌肉")
    bmr = models.FloatField(null=True, blank=True, verbose_name="基础代谢")
    bone_weight = models.FloatField(null=True, blank=True, verbose_name="骨质")
    fat_level = models.IntegerField(null=True, blank=True, verbose_name="肥胖等级")

    lbm = models.FloatField(null=True, blank=True, verbose_name="去脂体重")
    body_age = models.FloatField(null=True, blank=True, verbose_name="身体年龄")
    fat_control = models.FloatField(null=True, blank=True, verbose_name="脂肪控制")
    fatty_liver_risk = models.FloatField(null=True, blank=True, verbose_name="脂肪肝风险度")
    m_smm = models.FloatField(null=True, blank=True, verbose_name="标准肌肉")
    muscle_control = models.FloatField(null=True, blank=True, verbose_name="肌肉控制")
    physique = models.IntegerField(default=1, verbose_name='体型', null=True, blank=True, choices=PHYSIQUE_CHOICE)
    score = models.FloatField(null=True, blank=True, verbose_name="健康得分")
    standard_fat_percentage = models.FloatField(null=True, blank=True, verbose_name="标准体脂率")
    water_percentage = models.FloatField(null=True, blank=True, verbose_name="水分率")
    weight_control = models.FloatField(null=True, blank=True, verbose_name="体重控制量")
    bone_muscle_weight = models.FloatField(null=True, blank=True, verbose_name="骨骼肌")
    protein_weight = models.FloatField(null=True, blank=True, verbose_name="蛋白质")
    sw = models.FloatField(null=True, blank=True, verbose_name="标准体重")
    fat_weight = models.FloatField(null=True, blank=True, verbose_name="脂肪重量")
    weight = models.FloatField(null=True, blank=True, verbose_name="体重")

    bmi_max = models.FloatField(null=True, blank=True, verbose_name="bmi_max")
    bmi_min = models.FloatField(null=True, blank=True, verbose_name="bmi_min")
    bone_muscle_weight_max = models.FloatField(null=True, blank=True, verbose_name="骨骼肌正常范围上限")
    bone_muscle_weight_min = models.FloatField(null=True, blank=True, verbose_name="骨骼肌正常范围下限")
    bone_weight_max = models.FloatField(null=True, blank=True, verbose_name="骨质正常范围上限")
    bone_weight_min = models.FloatField(null=True, blank=True, verbose_name="骨质正常范围下限")
    fat_percentage_max = models.FloatField(null=True, blank=True, verbose_name="体脂百分比正常范围上限")
    fat_percentage_min = models.FloatField(null=True, blank=True, verbose_name="体脂百分比正常范围下限")
    fat_weight_max = models.FloatField(null=True, blank=True, verbose_name="脂肪正常范围上限")
    fat_weight_min = models.FloatField(null=True, blank=True, verbose_name="脂肪正常范围下限")
    muscle_weight_max = models.FloatField(null=True, blank=True, verbose_name="肌肉正常范围上限")
    muscle_weight_min = models.FloatField(null=True, blank=True, verbose_name="肌肉正常范围下限")
    protein_weight_max = models.FloatField(null=True, blank=True, verbose_name="蛋白质正常范围上限")
    protein_weight_min = models.FloatField(null=True, blank=True, verbose_name="蛋白质正常范围下限")
    sw_max = models.FloatField(null=True, blank=True, verbose_name="标准体重正常范围上限")
    sw_min = models.FloatField(null=True, blank=True, verbose_name="标准体重正常范围下限")
    visceral_fat_percentage_max = models.FloatField(null=True, blank=True, verbose_name="内脏脂肪上限")
    visceral_fat_percentage_min = models.FloatField(null=True, blank=True, verbose_name="内脏脂肪下限")
    water_weight_max = models.FloatField(null=True, blank=True, verbose_name="细胞总水正常范围上限")
    water_weight_min = models.FloatField(null=True, blank=True, verbose_name="细胞总水正常范围下限")
    weight_max = models.FloatField(null=True, blank=True, verbose_name="体重正常范围上限")
    weight_min = models.FloatField(null=True, blank=True, verbose_name="体重正常范围下限")

    fat_percentage_avg_sofar = models.FloatField(null=True, blank=True, verbose_name="体脂百分比正常范围上限")
    weight_avg_sofar = models.FloatField(null=True, blank=True, verbose_name="体重正常范围下限")
    used_count = models.IntegerField(null=True, blank=True, verbose_name="用户使用次数")

    class Meta:
        verbose_name = '身体数据'
        verbose_name_plural = '身体数据'
        db_table = 'body_data'

    def __str__(self):
        return "%s" % self.user.nick_name


class HealthEveryday(models.Model):
    """
    每日健康记录
    """
    user = models.ForeignKey('UserInfo', verbose_name="用户id")
    weight = models.FloatField(null=True, blank=True, verbose_name="体重(kg)")
    target_weight = models.FloatField(null=True, blank=True, verbose_name="目标体重(kg)")
    waist = models.FloatField(null=True, blank=True, verbose_name="腰围(cm)")
    photo = models.CharField(null=True, blank=True, verbose_name="每日健康记录图片", max_length=255)

    class Meta:
        verbose_name = '每日健康记录'
        verbose_name_plural = '每日健康记录'
        db_table = 'health_everyday'

    def __str__(self):
        return "%s" % self.user.nick_name


class AppEvaluateRecord(models.Model):
    """
    app评价记录
    """
    user = models.ForeignKey('UserInfo', verbose_name="用户id")
    evaluate_time = models.DateTimeField(null=True, blank=True, auto_now_add=True, verbose_name="评价时间")
    point = models.FloatField(null=True, blank=True, verbose_name="评价得分")
    text = models.TextField(null=True, blank=True, verbose_name="评价详情")

    class Meta:
        verbose_name = 'app评价记录'
        verbose_name_plural = 'app评价记录'
        db_table = 'app_evaluate_record'

    def __str__(self):
        return "%s" % self.user.nick_name


class FollowRecord(models.Model):
    """
    关注记录
    """
    following_user = models.ForeignKey('UserInfo', verbose_name="关注人id", related_name="following")
    followed_user = models.ForeignKey('UserInfo', verbose_name="被关注人id", related_name="followed")

    class Meta:
        verbose_name = '关注记录'
        verbose_name_plural = '关注记录'
        db_table = 'follow_record'


class AffairsRecord(models.Model):
    user = models.ForeignKey('UserInfo', verbose_name="发布人id")
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    affair_text = models.TextField(null=True, blank=True, verbose_name="动态文字")
    affair_photo = models.CharField(null=True, blank=True, verbose_name="动态图片", max_length=1024)
    browse_num = models.IntegerField(null=True, blank=True, verbose_name="浏览量", default=0)
    base_thumbs_num = models.IntegerField(null=True, blank=True, verbose_name="基础点赞量", default=0)
    thumbs_num = models.IntegerField(null=True, blank=True, verbose_name="点赞量", default=0)
    begin_weight = models.FloatField(null=True, blank=True, verbose_name="起始体重")
    present_weight = models.FloatField(null=True, blank=True, verbose_name="当前体重")
    target_weight = models.FloatField(null=True, blank=True, verbose_name="目标体重")
    is_delete = models.BooleanField(default=False, verbose_name="是否删除")
    is_recommend = models.BooleanField(default=False, verbose_name="是否推荐")
    longitude = models.DecimalField(null=True, default=None, max_digits=10, decimal_places=7, verbose_name="经度")
    latitude = models.DecimalField(null=True, default=None, max_digits=10, decimal_places=7, verbose_name="纬度")
    is_thumb = None

    class Meta:
        verbose_name = '动态记录'
        verbose_name_plural = '动态记录'
        db_table = 'affairs_record'


class ThumbRecord(models.Model):
    affair = models.ForeignKey('AffairsRecord', verbose_name="动态id")
    user = models.ForeignKey('UserInfo', null=True, blank=True, verbose_name="操作人id",related_name="thumb_user")
    operation_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")

    class Meta:
        verbose_name = '动态点赞记录'
        verbose_name_plural = '动态点赞记录'
        db_table = 'thumb_record'


class CommentRecord(models.Model):
    affair = models.ForeignKey('AffairsRecord', verbose_name="动态id")
    user = models.ForeignKey('UserInfo', null=True, blank=True, verbose_name="评论人id")
    operation_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    comment_text = models.CharField(max_length=140, verbose_name="评论内容")
    father = models.ForeignKey('self', null=True, blank=True, verbose_name="父级评论id")
    top = models.IntegerField(null=True, blank=True, verbose_name="顶级评论id")
    level = models.IntegerField(default=1, verbose_name="评论层级")

    class Meta:
        verbose_name = '动态评论记录'
        verbose_name_plural = '动态评论记录'
        db_table = 'comment_record'

    def __str__(self):
        return "%s" % self.comment_text

    def __repr__(self):
        return "%s" % self.comment_text


class TrainCategory(models.Model):
    name = models.CharField(null=True, blank=True, verbose_name="训练类别名字", max_length=10)
    father = models.ForeignKey('self', null=True, blank=True, verbose_name="上级类别")

    class Meta:
        verbose_name = '训练类别'
        verbose_name_plural = '训练类别'
        db_table = 'train_category'

    def __str__(self):
        return "%s" % self.name


class Training(models.Model):
    background_image = models.CharField(max_length=200, verbose_name="背景图", null=True,
                                        blank=True)
    cover_image = models.CharField(max_length=200, verbose_name="封面图", null=True,
                                   blank=True)
    train_category = models.ForeignKey('TrainCategory', verbose_name="所属类别", null=True,
                                       blank=True)
    browse_num = models.IntegerField(null=True, blank=True, verbose_name="浏览量", default=0)
    base_browse_num = models.IntegerField(null=True, blank=True, verbose_name="基础浏览量", default=0)
    join_num = models.IntegerField(null=True, blank=True, verbose_name="加入量", default=0)
    introduce = models.CharField(null=True, blank=True, verbose_name="文字介绍", max_length=1024)
    name = models.CharField(null=True, blank=True, verbose_name="训练名字", max_length=10)
    train_video = models.CharField(max_length=1000, verbose_name="训练视频", null=True,
                                   blank=True)
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    is_delete = models.BooleanField(default=False, verbose_name="是否删除")
    is_recommend = models.BooleanField(default=True, verbose_name="是否推荐")
    is_warm_up = models.BooleanField(default=False, verbose_name="是否热身")
    is_top = models.BooleanField(default=False, verbose_name="是否置顶")
    order = models.IntegerField(verbose_name="排序", default=None, null=True, blank=True)

    class Meta:
        verbose_name = '训练详情'
        verbose_name_plural = '训练详情'
        db_table = 'training'

    def __str__(self):
        return "%s" % self.name


class UserSign(models.Model):
    user = models.ForeignKey('UserInfo', verbose_name="签到人id")
    sign_date = models.CharField(null=True, blank=True, verbose_name="签到日期", max_length=10)
    sign_year = models.IntegerField(null=True, blank=True, verbose_name="签到年", default=2017)
    sign_month = models.IntegerField(null=True, blank=True, verbose_name="签到月", default=1)
    sign_day = models.IntegerField(null=True, blank=True, verbose_name="签到日", default=1)
    experience = models.IntegerField(null=True, blank=True, verbose_name="签到经验", default=0)

    class Meta:
        verbose_name = '签到'
        verbose_name_plural = '签到'
        db_table = 'user_sign'


class RewardRecord(models.Model):
    user = models.ForeignKey('UserInfo', verbose_name="打赏人id")
    affairs = models.ForeignKey('AffairsRecord', verbose_name="帖子id")
    reward_money = models.DecimalField(default=0, max_digits=15, decimal_places=2, null=True, blank=True,
                                       verbose_name='打赏金额')
    reward_time = models.DateTimeField(auto_now_add=True, verbose_name="打赏时间")

    class Meta:
        verbose_name = '打赏记录'
        verbose_name_plural = '打赏记录'
        db_table = 'reward_record'


class Information(models.Model):
    TYPE_CHOISE = ((1, "富文本"), (2, "链接"))
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="发布时间")
    background_image = models.CharField(max_length=200, verbose_name="背景图", null=True,
                                        blank=True)
    cover_image = models.CharField(max_length=200, verbose_name="封面图", null=True,
                                   blank=True)
    info_text = models.TextField(null=True, blank=True, verbose_name="正文")
    info_title = models.CharField(null=True, blank=True, verbose_name="标题", max_length=40)
    read_number = models.IntegerField(null=True, blank=True, verbose_name="阅读量", default=0)
    is_delete = models.BooleanField(verbose_name="是否删除", default=False)
    url = models.CharField(max_length=500, verbose_name="链接", null=True, blank=True)
    type = models.IntegerField(choices=TYPE_CHOISE, verbose_name="富文本 还是链接", default=1)
    order = models.IntegerField(verbose_name="排序", default=None, null=True, blank=True)
    is_top = models.BooleanField(verbose_name="是否置顶", default=False)

    class Meta:
        verbose_name = '资讯'
        verbose_name_plural = '资讯'
        db_table = 'information'


class Token(models.Model):
    user = models.ForeignKey('AppUser', verbose_name="登录id")
    token = models.UUIDField(verbose_name="登录凭证")
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    modify_time = models.DateTimeField(auto_now=True, verbose_name="修改时间")

    class Meta:
        verbose_name = 'token'
        verbose_name_plural = 'token'
        db_table = 'token'


class ExperienceRecord(models.Model):
    user = models.ForeignKey('UserInfo', verbose_name="用户信息")
    sign_date = models.CharField(null=True, blank=True, verbose_name="签到日期", max_length=10)
    experience = models.IntegerField(null=True, blank=True, verbose_name="签到经验", default=0)
    experience_type = models.ForeignKey("ExperienceTypeModel", null=True, blank=True, verbose_name="经验类型", default=None)

    class Meta:
        verbose_name = '经验记录'
        verbose_name_plural = '经验记录'
        db_table = 'experience_record'


class JoinTrainRecord(models.Model):
    user = models.ForeignKey('UserInfo', null=True, blank=True, verbose_name="用户信息")
    train = models.ForeignKey('Training', null=True, blank=True, verbose_name="训练信息")

    class Meta:
        verbose_name = '训练加入记录'
        verbose_name_plural = '训练加入记录'
        db_table = 'join_train_record'


class AdminUser(models.Model):
    account = models.CharField(max_length=20, verbose_name='后台登录账户')
    password = models.CharField(max_length=20, verbose_name='后台登录账户')
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")

    class Meta:
        verbose_name = '后台管理员账号'
        verbose_name_plural = '后台管理员账号'
        db_table = 'admin_user'


class ShareRecord(models.Model):
    user = models.ForeignKey('UserInfo', null=True, blank=True, verbose_name="用户信息")
    affair = models.ForeignKey('AffairsRecord', null=True, blank=True, verbose_name="训练信息")
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")

    class Meta:
        verbose_name = '分享记录'
        verbose_name_plural = '分享记录'
        db_table = 'share_record'


class AppVersionModel(models.Model):
    version = models.CharField(unique=True, max_length=16, verbose_name="版本号")
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    during_apple_verification = models.BooleanField(default=True, verbose_name="是否在苹果验证期间")
    allow_third_login = models.BooleanField(default=True, verbose_name="兼容字段")
    has_new_verion = models.BooleanField(default=False, verbose_name="是否有新版本")
    must_update = models.BooleanField(default=False, verbose_name="是否强制更新")
    download_url = models.CharField(max_length=200, null=True, verbose_name="新版本下载地址")

    class Meta:
        verbose_name = '版本控制'
        verbose_name_plural = '版本控制'
        db_table = 'lucky_app_version'


class CommonProblemTypeModel(models.Model):
    name = models.CharField(max_length=50, unique=True, verbose_name="名称")
    sort_no = models.IntegerField(default=0, verbose_name="排序号")
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    is_delete = models.BooleanField(default=False, verbose_name="是否删除")

    class Meta:
        ordering = ("sort_no",)
        verbose_name = "常见问题类型"
        verbose_name_plural = "常见问题类型"
        db_table = "common_problem_type"


class CommonProblemModel(models.Model):
    title = models.CharField(max_length=100, verbose_name="标题")
    content = models.TextField(verbose_name="内容")
    type = models.ForeignKey("CommonProblemTypeModel", verbose_name="常见问题类型id")
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    sort_no = models.IntegerField(default=0, verbose_name="排序")
    is_delete = models.BooleanField(default=False, verbose_name="是否删除")

    class Meta:
        ordering = ("sort_no",)
        verbose_name = "常见问题"
        verbose_name_plural = "常见问题"
        db_table = "common_problem"


class SuggestionRecordModel(models.Model):
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    content = models.CharField(max_length=1000, verbose_name="内容")
    user = models.ForeignKey("UserInfo", verbose_name="用户")

    class Meta:
        ordering = ("-create_time",)
        verbose_name = "用户意见反馈"
        verbose_name_plural = "用户意见反馈"
        db_table = "suggestion_record"


class ExperienceTypeModel(models.Model):
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    name = models.CharField(null=False, max_length=100, verbose_name="名称")
    day_max_num = models.IntegerField(null=False, verbose_name="每日最大获取数量")
    incr_num = models.IntegerField(null=False, verbose_name="每次增加数量")
    is_delete = models.BooleanField(default=False, verbose_name="是否刪除")

    class Meta:
        verbose_name = "积分类型表"
        verbose_name_plural = verbose_name
        db_table = "experience_type"


class BanNameModel(models.Model):
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    name = models.CharField(null=False, max_length=100, verbose_name="名称")
    is_delete = models.BooleanField(default=False, verbose_name="是否刪除")

    class Meta:
        verbose_name = "禁止使用的昵称"
        verbose_name_plural = verbose_name
        db_table = "ban_name"


class ApkVersionModel(models.Model):
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    version_no = models.CharField(max_length=100, verbose_name="版本号")
    version_description = models.CharField(max_length=1000, verbose_name="版本描述")
    is_delete = models.BooleanField(default=False, verbose_name="是否删除")

    class Meta:
        verbose_name = "apk版本信息"
        verbose_name_plural = verbose_name
        db_table = "apk_version"


class HardwareVersionModel(models.Model):
    CATEGORY_CHOICES = (("00", "未知"), ("01", "连体衣"), ("02", "上衣"), ("03", "裤子"))
    MANUFACTURE_CHOICES = (("0000", "Smart Clothing(default)"), ("0001", "Smart Clothing"))
    HW_VERSION_CHOICES = (("0000", "HW Version 3.0 20170626"), ("0001", "HW Version 3.1 20170808"))

    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    category = models.CharField(choices=CATEGORY_CHOICES, max_length=10, verbose_name="智能衣类别")
    manufacture = models.CharField(choices=MANUFACTURE_CHOICES, max_length=10, verbose_name="智能衣制造厂商")
    hw_version = models.CharField(choices=HW_VERSION_CHOICES, max_length=10, verbose_name="智能衣硬件的版本")
    fw_version = models.CharField(max_length=1000, verbose_name="智能衣的固件(应用部分)版本")
    hardware_url = models.CharField(max_length=1000, verbose_name="路径")
    is_delete = models.BooleanField(default=False, verbose_name="是否删除")

    class Meta:
        verbose_name = "硬件版本维护版本信息"
        verbose_name_plural = verbose_name
        db_table = "hardware_version"


class UserBodyDimension(models.Model):
    user = models.ForeignKey('UserInfo', verbose_name="app_user_info")
    body_weight = models.IntegerField("body_weight")#, verbose_name)#, verbose_name="体重(kg)")
    upper_bust = models.IntegerField("upper_bust")#, verbose_name)#, verbose_name="上胸围(cm)")
    lower_bust = models.IntegerField("lower_bust")#, verbose_name)#, verbose_name="下胸围(cm)")
    waist_circumference = models.IntegerField("waist_circumference")#, verbose_name)#, verbose_name="腰围(cm)")
    hip_circumference = models.IntegerField("hip_circumference")#, verbose_name)#, verbose_name="臀围(cm)")
    left_thigh = models.IntegerField("left_thigh")#, verbose_name)#, verbose_name="左大腿(cm)")
    right_thigh = models.IntegerField("right_thigh")#, verbose_name)#, verbose_name="右大腿(cm)")
    left_arm = models.IntegerField("left_arm")#, verbose_name)#, verbose_name="左手臂(cm)")
    right_arm = models.IntegerField("right_arm")#, verbose_name)#, verbose_name="右手臂(cm)")
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    last_update_time = models.DateTimeField(auto_now=True, verbose_name="最后更新时间")
    is_delete = models.BooleanField(default=False, verbose_name='是否删除')

    class Meta:
        verbose_name = "用户身体维度信息"
        verbose_name_plural = verbose_name
        db_table = "user_body_dimension"
